<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$router->get('/', function () use ($router) {
    return $router->app->version();
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('oauth/token', 'OauthController@getToken');
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('my/project', 'MyController@getProject');
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('user', 'UserController@index');
    $router->get('user/{id}', 'UserController@getUser');
    $router->post('user', 'UserController@createUser');
    $router->put('user/{id}', 'UserController@updateUser');
    $router->delete('user/{id}', 'UserController@deleteUser');
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('module', 'ModuleController@index');
    $router->get('module/{id}', 'ModuleController@getModule');
    $router->post('module', 'ModuleController@createModule');
    $router->put('module/{id}', 'ModuleController@updateModule');
    $router->delete('module/{id}', 'ModuleController@deleteModule');
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('project', 'ProjectController@index');
    $router->get('project/{id}', 'ProjectController@getProject');
    $router->get('project/{id}/modules', 'ProjectController@getProjectModules');
    $router->get('project/{id}/tasks', 'ProjectController@getProjectTasks');
    $router->get('project/{id}/users', 'ProjectController@getProjectUsers');
    $router->post('project', 'ProjectController@createProject');
    $router->put('project/{id}', 'ProjectController@updateProject');
    $router->delete('project/{id}', 'ProjectController@deleteProject');
});

$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('task', 'TaskController@index');
    $router->get('task/{id}', 'TaskController@getTask');
    $router->post('task', 'TaskController@createTask');
    $router->put('task/{id}', 'TaskController@updateTask');
    $router->delete('task/{id}', 'TaskController@deleteTask');
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('user-task', 'UserTaskController@index');
    $router->get('user-task/{id}', 'UserTaskController@getUserTask');
    $router->post('user-task', 'UserTaskController@createUserTask');
    $router->put('user-task/{id}', 'UserTaskController@updateUserTask');
    $router->delete('user-task/{id}', 'UserTaskController@deleteUserTask');
});


$router->group(['prefix' => 'api/v1'], function ($router) {
    $router->get('user-project', 'UserPrjectController@index');
    $router->get('user-task/{id}', 'UserTaskController@getUserTask');
    $router->post('user-task', 'UserTaskController@createUserTask');
    $router->put('user-task/{id}', 'UserTaskController@updateUserTask');
    $router->delete('user-task/{id}', 'UserTaskController@deleteUserTask');
});
